<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:directive.page import="com.db.BaseDAO"/>



<%
String path = request.getContextPath();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />

		<link rel="stylesheet" type="text/css" href="<%=path%>/css/base.css" />
        <script>
          function check(){
          
            var regy = /^\d+$/gi;
            var regx = /^\d+$/gi;
            var regs = /^\d+$/gi;
           
            var roomno =document.getElementById("roomno").value;
            var num =document.getElementById("num").value;
            var freeNum =document.getElementById("free").value;
            
             if(!regy.test(roomno)){
              alert("请输入正确的宿舍号!");
              return false;
            }
             if(!regx.test(num)){
              alert("请输入正确的床位数!");
              return false;
            }
            if(!regs.test(freeNum)){
              alert("请输入正确的未使用床位数!");
              return false;
            }
           return true;
          }
        </script>
	</head>

	<body leftmargin="2" topmargin="9"
		background='<%=path%>/images/allbg.gif'>
		<form action="<%=path%>/room!add.action" name="formAdd"
			method="post" onsubmit="return check();">
			<table width="98%" align="center" border="0" cellpadding="4"
				cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px">
				<tr bgcolor="#EEF4EA">
					<td colspan="3" background="<%=path%>/images/wbg.gif" class='title'>
						<span>添加</span>
					</td>
				</tr>
	<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
					区域：
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
							<select name="data.area">
						  <%
						     BaseDAO dao = new BaseDAO();
						     List<Object[]> all = dao.find("select distinct area from flat",null);
						     for(Object[] data:all){
						   %>
						     <option><%=data[0]%></option>
						   <% } %>
						</select>
					</td>
				</tr>

				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
						楼栋号：
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
						<!--  	<select name="data.flat">
						  <%
						    
						     List<Object[]> all2 = dao.find("select * from data.flat",null);
						     for(Object[] data:all2){
						   %>
						     <option><%=data[1]%></option>
						   <% } %>
						</select>-->
						
						
						
						<select name="data.flat">
						  <option>1</option>
						  <option>2</option>
						  <option>3</option>
						  <option>4</option>
						  <option>5</option>
						  <option>6</option>
						  <option>7</option>
						  <option>8</option>
			
						</select>
					</td>
				</tr>
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
						宿舍号：
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
						<input name="data.roomno" id="roomno" />
					</td>
				</tr>
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
						床位数：
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
						<input name="data.num" id="num"/>
					</td>
				</tr>
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
						未使用床位数：
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
						<input name="data.freeNum" id="free"/>
					</td>
				</tr>
				<tr align='center' bgcolor="#FFFFFF"
					onMouseMove="javascript:this.bgColor='red';"
					onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
					<td width="25%" bgcolor="#FFFFFF" align="right">
						&nbsp;
					</td>
					<td width="75%" bgcolor="#FFFFFF" align="left">
						<input type="submit" value="提交" />
						&nbsp;
						<input type="reset" value="重置" />
						&nbsp;
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
